<?php
session_start();
if (!empty($_GET['idpractica'])) {
    $id = $_GET['idpractica'];
    $semestres = array("--", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X");
}

include 'database.class.php';
$db = new Database();
$db->dbConnect();
$sql = mysql_query("SELECT
      nombrepra
    , empresa
    , fechaini
    , fechafin
    , programa
    , asesor
    , observaciones
    , informe
    , certificado
    , ciclo
    , tipopractica
    , estadopractica
FROM
    practica WHERE
        idpractica= $id");
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link href="css/default.css" rel="stylesheet" type="text/css" />
        <link href="css/redmond.datepick.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="js/jquery-1.4.3.js"></script>
        <script type="text/javascript" src="js/jquery-ui-1.8.6.custom.min.js"></script>
        <script type="text/javascript" src="js/jquery.validate.js" ></script>
        <script type="text/javascript" src="js/jquery.datepick.js" ></script>
        <script type="text/javascript" src="js/jquery.datepick-es.js" ></script>
        <script type="text/javascript">
            $(function(){
                $('#empresa1').autocomplete({
                    source : 'ajax-form-cargaremp.php',
                    select : function(event, ui){
                        $('#resemp').html(
                        '<h2>Resultado de la busqueda</h2>' +
                            '<strong>Codigo de la empresa: </strong>' + ui.item.value +'<br/>'+
                            '<strong>Nombre de la empresa: </strong>' + ui.item.nom_emp +'<br/>'
                    );
                    }
                });
            });
        </script>
        <script type="text/javascript">
            $(document).ready(function() {
                $("#form-contacto").validate();
            });
        </script>
        <script type="text/javascript">
            $(function() {
                $('#fini').datepick({ dateFormat: 'yyyy-mm-dd' });
                $('#fini').datepick({onSelect: showDate});
                $('#ffin').datepick({ dateFormat: 'yyyy-mm-dd' });
                $('#ffin').datepick({onSelect: showDate});
            });
            function showDate(date) {
                alert('The date chosen is ' + date);
            }
        </script>
        <style type="text/css">
            #commentForm { width: 500px; }
            #commentForm label { width: 250px; }
            #commentForm label.error, #commentForm input.submit { margin-left: 253px; }
        </style>
        <title>Editar Pasantia</title>
    </head>
    <!--body-->
    <body>
        <div id="wrapper">
            <?php include 'include/header.php'; ?>
            <!-- end div#header -->
            <div id="page">
                <div id="content">
                    <div id="welcome">
                        <h1>Editar Pasantia</h1>
                        <p><img src="images/warning.png" width="30" height="30">  El codigo de la pasantia no podra ser modificado</p>

                        <div id="form-area">

                            <h2>Editar Pasantia <?php echo $id ?></h2>
                            <form action="include/actualizar-form-pas.php" method="post" id="form-contacto">
                                <fieldset>
                                    <?php
                                    while ($fila = mysql_fetch_array($sql)) {
                                    ?>
                                        <dl>
                                            <dt><label for="codigo" style="visibility: hidden">Codigo *</label></dt>
                                            <dd><input type="hidden" name="codigo" id="codigo" value="<?php echo $id ?>" class="digits required"/></dd>
                                            <div style="clear: both; height: 1px"></div>
                                            <dt><label for="nombre">Nombre *</label></dt>
                                            <dd><input type="text" name="nombre" id="nombre" value="<?php echo$fila["nombrepra"]; ?>" class="required" minlength="2"/></dd>
                                            <div style="clear: both; height: 1px"></div>
                                            <dt><label for="empresa1">Codigo Empresa *<br><strong>(Busque por nombre de la empresa)</strong></label></dt>
                                            <dd><input type="text" name="empresa1" id="empresa1" value="<?php echo$fila["empresa"]; ?>" class="required" minlength="2" /></dd>
                                            <dd><p id="resemp"></p> </dd>
                                            <div style="clear:both"></div>

                                            <dt><label for="programa">Programa *</label></dt>
                                            <dd><select name="programa" id="programa" class="required">
                                                <?php
                                                if ($fila["programa"] == "ingenieria de software") {
                                                    echo "<option value='ingenieria de software' selected>Ingenieria de software</option>
                                                  <option value='ingenieria mecatronica' >Ingenieria mecatronica</option>";
                                                }elseif ($fila["programa"] == "ingenieria mecatronica"){
                                                    echo "<option value='ingenieria de software' >Ingenieria de software</option>
                                                  <option value='ingenieria mecatronica' selected>Ingenieria mecatronica</option>";
                                                }else {
                                                    return null;
                                                }
                                                ?>
                                            </select>
                                        </dd>
                                        <div style="clear: both; height: 1px"></div>
                                        <dt><label for="ciclo">Ciclo *</label></dt>
                                        <dd><select name="ciclo" id="ciclo" class="required">

                                                <?php
                                                if ($fila["ciclo"] == "1") {
                                                    echo "<option value='1' selected>Tecnico</option>
                                                  <option value='2' >Tecnologico</option>
                                                  <option value='3' >Profesional</option>";
                                                } elseif ($fila["ciclo"] == "2") {
                                                    echo "<option value='1' >Tecnico</option>
                                                  <option value='2' selected>Tecnologico</option>
                                                  <option value='3' >Profesional</option>";
                                                } else {
                                                    echo "<option value='1' >Tecnico</option>
                                                  <option value='2' >Tecnologico</option>
                                                  <option value='3' selected>Profesional</option>";
                                                }
                                                ?>
                                            </select>
                                        </dd>
                                        <div style="clear: both; height: 1px"></div>
                                        <dt><label for="tipo">Tipo pasantia *</label></dt>
                                        <dd><select name="tipo" id="tipo" class="required">
                                                 <?php
                                                if ($fila["tipopractica"] == "1") {
                                                    echo "<option value='1' selected>Por resultados</option>
                                                  <option value='2' >Por horas</option>";
                                                }elseif ($fila["tipopractica"] == "2"){
                                                    echo "<option value='1' >Por resultados</option>
                                                  <option value='2' selected>Por horas</option>";
                                                }else {
                                                    return null;
                                                }
                                                ?>
                                            </select>
                                        </dd>
                                        <div style="clear: both; height: 1px"></div>
                                        <dt><label for="informe">Informe? *</label></dt>
                                        <dd><select name="informe" id="informe" class="required">
                                                <?php
                                                if ($fila["informe"] == "1") {
                                                    echo "<option value='0'>No</option>
                                                        <option value='1' selected>Si</option>";
                                                } else {
                                                    echo "<option value='0' selected>No</option>
                                                        <option value='1' >Si</option>";
                                                }
                                                ?>
                                            </select>
                                        </dd>
                                         <div style="clear: both; height: 1px"></div>
                                        <dt><label for="certificado">Certificado? *</label></dt>
                                        <dd><select name="certificado" id="certificado" class="required">
                                                   <?php
                                                if ($fila["certificado"] == "1") {
                                                    echo "<option value='0'>No</option>
                                                        <option value='1' selected>Si</option>";
                                                } else {
                                                    echo "<option value='0' selected>No</option>
                                                        <option value='1' >Si</option>";
                                                }
                                                ?>
                                            </select>
                                        </dd>
                                         <div style="clear: both; height: 1px"></div>
                                        <dt><label for="fini">Fecha inicio *</label></dt>
                                        <dd><input type="text" name="fini" id="fini" value="<?php echo$fila["fechaini"]; ?>" class="required" /></dd>
                                        <dt><label for="ffin">Fecha fin *</label></dt>
                                        <dd><input type="text" name="ffin" id="ffin" value="<?php echo$fila["fechafin"]; ?>" class="required" /></dd>
                                        <dt><label for="asesor">Asesor </label></dt>
                                        <dd><input type="text" name="asesor" id="asesor" value="<?php echo$fila["asesor"]; ?>" minlength="2"/></dd>
                                        
                                        <dt><label for="observaciones">Observaciones</label></dt>
                                        <dd><input type="text"  name="observaciones" id="observaciones" value="<?php echo$fila["observaciones"]; ?>" minlength="2"/></dd>
                                        <dt><label for="estado">Estado</label></dt>
                                        <dd>
                                            <select name="estado" id="estado" class="required">
                                                <?php
                                                if ($fila["estadopractica"] == "0") {
                                                    echo "<option value='0'selected>Sin Iniciar</option>
                                                        <option value='1' >En Ejecucion</option>
														<option value='2' >Concluida</option>
														<option value='3' >Inconclusa</option>";
                                                } elseif ($fila["estadopractica"] == "1"){
                                                    echo "<option value='0'>Sin Iniciar</option>
                                                        <option value='1' selected>En Ejecucion</option>
														<option value='2' >Concluida</option>
														<option value='3' >Inconclusa</option>";
                                                }elseif ($fila["estadopractica"] == "2"){
                                                    echo "<option value='0'>Sin Iniciar</option>
                                                        <option value='1' >En Ejecucion</option>
														<option value='2' selected>Concluida</option>
														<option value='3' >Inconclusa</option>";
                                                }elseif ($fila["estadopractica"] == "3"){
                                                    echo "<option value='0'>Sin Iniciar</option>
                                                        <option value='1' >En Ejecucion</option>
														<option value='2' >Concluida</option>
														<option value='3' selected>Inconclusa</option>";
                                                }
                                                ?>
                                            </select>
                                        </dd>

                                        <dt class="center">
                                            <input type="submit" name="submit" title="Guardar" id="submit" value="" style="background-image:url(images/Save.png); width:50px; background-repeat:no-repeat; background-position:center;"/>

                                            <input type="reset" name="button" title="Restaurar"id="button" value="" style="background-image:url(images/Undo.png); width:50px; background-repeat:no-repeat; background-position:center;"/>
                                        </dt>
                                    </dl>
                                    <?php
                                            }
                                    ?>
                                        </fieldset>
                                    </form>

                                </div>
                            </div>
                            <!-- end div#welcome -->
                        </div>
                        <!-- end div#content -->
                        <div id="sidebar">
                            <ul>
                        <?php include 'include/nav.php'; ?>
                                            <!-- end navigation -->
                                        </ul>
                                    </div>
                                    <!-- end div#sidebar -->
                                    <div style="clear: both; height: 1px"></div>
                                </div>
            <?php include 'include/footer.php'; ?>
        </div>
        <!-- end div#wrapper -->
    </body>
    <!--body ends-->
</html>